package day26;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;

/**
 * @author ZJX
 * @version 1.0
 * @descption
 * @since 2025/11/3 19:50
 */
public class Day20 {
//    public static void main(String[] args) throws IOException {
//        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//        PrintWriter out = new PrintWriter(System.out);
//        in.nextToken();
//        int a = (int) in.nval;
//        in.nextToken();
//        int h = (int) in.nval;
//        in.nextToken();
//        int b = (int) in.nval;
//        in.nextToken();
//        int k = (int) in.nval;
//        long ret = 0;
//        int n = Math.min(k / a, h / b); // 最多的次数
//        ret += (long) (a + b) * n;
//        int GX = k - n * a; // 光剩余
//        int DX = h - n * b; // 对立剩余
//        if (GX <= 0 && DX <= 0) {
//            out.println(ret);
//        } else if (GX > 0 && DX > 0) {
//            GX -= a;
//            DX -= b;
//            if (GX <= 0 && DX <= 0) {
//                ret += (long) (a + b);
//                out.println(ret);
//            } else {
//                long remain = (GX > 0) ? 10L * b : 10L * a;
//                ret += (remain + (a + b));
//                out.println(ret);
//            }
//        } else {
//            long remain = (GX > 0) ? 10L * b : 10L * a;
//            ret += remain;
//            out.println(ret);
//        }
//
//        out.close();
//    }

//    public static void main(String[] args) throws IOException {
//        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//        PrintWriter out = new PrintWriter(System.out);
//        in.nextToken();
//        int n = (int) in.nval;
//        int[] nums = new int[n];
//        for (int i = 0; i < n; i++) {
//            in.nextToken();
//            nums[i] = (int) in.nval;
//        }
//        long cur = nums[0];
//        long max = nums[0];
//        for (int i = 1; i < n; i++) {
//            cur = Math.max(nums[i], cur + nums[i]);
//            max = Math.max(max, cur);
//        }
//        out.println(max);
//        out.close();
//    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String s = br.readLine();
        if (!isPalindrome(s)) {
            out.println(s.length());
        } else {
            if (allCharsSame(s)) {
                out.println(0);
            } else {
                out.println(s.length() - 1);
            }
        }
        out.close();
    }

    // 判断字符串是否为回文
    private static boolean isPalindrome(String s) {
        int l = 0, r = s.length() - 1;
        while (r > l) {
            if (s.charAt(l) != s.charAt(r)) {
                return false;
            }
            l++;
            r--;
        }
        return true;
    }

    // 判断所有字符是否相同
    private static boolean allCharsSame(String s) {
        for (int i = 1; i < s.length(); i++) {
            char first = s.charAt(0);
            if (s.charAt(i) != first) {
                return false;
            }
        }
        return true;
    }

    public int[][] merge(int[][] intervals) {
        if (intervals == null || intervals.length < 1) {
            return intervals;
        }
        Arrays.sort(intervals, (a, b) -> a[0] - b[0]);
        List<int[]> ret = new LinkedList<>();
        int end = intervals[0][1];
        ret.add(intervals[0]);
        for (int i = 1; i < intervals.length; i++) {
            if (intervals[i][0] <= end) {
                end = Math.max(end, intervals[i][1]);
                ret.get(ret.size() - 1)[1] = end;
            } else {
                ret.add(intervals[i]);
                end = intervals[i][1];
            }
        }
        return ret.toArray(new int[ret.size()][]);
    }

    public int minDistance(String word1, String word2) {
        int m = word1.length();
        int n = word2.length();
        int[][] dp = new int[m + 1][n + 1]; // dp[i][j]表示word1的前i个->word2的前j的最小操作数

//        初始化
        for (int i = 0; i <= m; i++) {
            dp[i][0] = i; // j=0（word2空）：需要i次删除
        }
        for (int j = 0; j <= n; j++) {
            dp[0][j] = j; // i=0（word1空）：需要j次插入
        }
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                if (word1.charAt(i - 1) == word2.charAt(j - 1)) {
                    dp[i][j] = dp[i - 1][j - 1];
                } else {
                    dp[i][j] = Math.min(dp[i - 1][j], Math.min(dp[i][j - 1], dp[i - 1][j - 1])) + 1;
                }
            }
        }
        return dp[m][n];
    }

    public int myAtoi(String s) {
        int i = 0;
        int n = s.length();
        while (i < n && s.charAt(i) == ' ') {
            i++;
        }
        int sign = 1;
        if (i < n && s.charAt(i) == '+') {
            i++;
        } else if (i < n && s.charAt(i) == '-') {
            i++;
            sign = -1;
        }
        int ret = 0;
        while (i < n && Character.isDigit(s.charAt(i))) {
            int digit = s.charAt(i) - '0';
            if (ret > (Integer.MAX_VALUE - digit) / 10) {
                return sign == 1 ? Integer.MAX_VALUE : Integer.MIN_VALUE;
            } else {
                ret = ret * 10 + digit;
            }
            i++;
        }
        return ret * sign;
    }

    public int longestValidParentheses(String s) {
        int n = s.length();
        int maxLen = 0;
        Stack<Integer> stack = new Stack<>();
        stack.push(-1);
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '(') {
                stack.push(i);
            } else {
                stack.pop();
                if (stack.isEmpty()) {
                    stack.push(i);
                } else {
                    maxLen = Math.max(maxLen, i - stack.peek());
                }
            }
        }
        return maxLen;
    }
}

